package com.heima.comment.Controller;

import com.heima.comment.dto.CommentDto;
import com.heima.comment.dto.CommentLikeDto;
import com.heima.comment.dto.CommentSaveDto;
import com.heima.comment.service.ICommentService;
import com.heima.common.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @BelongsProject: heima-leadnews
 * @BelongsPackage: com.heima.comment.Controller
 * @Author: wangjian
 * @CreateTime: 2022-07-05  23:51
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {
    @Autowired
    private ICommentService commentService;

/**
 * @description: 发表评论
 * @author: wangjian
        * @date: 2022/7/5 23:52
 * @param: dto
 * @return: com.heima.common.dto.ResponseResult
 **/
    @PostMapping("/save")
    public ResponseResult saveComment(@RequestBody CommentSaveDto dto) {
        return commentService.saveComment(dto);
    }
  /**
   * @description: 加载评论列表
   * @author: wangjian
          * @date: 2022/7/6 18:12
   * @param: dto
   * @return: com.heima.common.dto.ResponseResult
   **/
    @PostMapping("/load")
    public ResponseResult load(@RequestBody CommentDto dto) {
        return commentService.load(dto);
    }
  /**
   * @description: 点赞某一条评论
   * @author: wangjian
          * @date: 2022/7/6 18:15
   * @param: dto
   * @return: com.heima.common.dto.ResponseResult
   **/
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto){
        return commentService.like(dto);
    }









}

